﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SignalShopBase;

namespace TestModule
{
    public class F2TModule : SignalShopModule
    {
        public F2TModule() : base(NAME, PATH) { }

        public override void Execute(Signal target, Signal source)
        {
            int N = target.N;

            Signal temp = new Signal(N);
            Complex sum = new Complex();
            Complex c = new Complex();

            for (int n = -N; n <= N; n++)
            {
                double t = (n * 1.0) / (2 * N + 1);             
                sum.Set(0.0, 0.0);                

                for (int f = -N; f <= N; f++)
                {
                    double w = 2.0 * Math.PI * f;
                    sum.Add(c.Set(target[f]).Rot(w * t));
                }

                temp[n].Set(sum);
            }

            for (int n = -N; n <= N; n++)
            {
                target[n].Set(temp[n]);
            }
        }

        private const string NAME = "F2T";
        private const string PATH = "Transform/F2T";
    }
}
